﻿
Imports BUS, DTO
Public Class frmlapthedocgia

    Private Sub frmlapthedocgia_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ldgBUS As New LoaiDocGiaBUS()
        Dim dsldg As New List(Of LoaiDocGiaDTO)
        dsldg = ldgBUS.LayDSLoaiDocGia()
        LookUpEdit_LoaiDocGia.Properties.DataSource = dsldg
        LookUpEdit_LoaiDocGia.Properties.ValueMember = "MaLoaiDocGia"
        LookUpEdit_LoaiDocGia.Properties.DisplayMember = "MaLoaiDocGia"
        LookUpEdit_LoaiDocGia.EditValue = 0

        Dim nhanvienBUS As New NhanVienBUS()
        Dim dsnhanvien As New List(Of NhanVienDTO)
        dsnhanvien = nhanvienBUS.LayDSNhanVien_ThuThu()
        LookUpnguoilap.Properties.DataSource = dsnhanvien
        LookUpnguoilap.Properties.ValueMember = "MaNhanVien"
        LookUpnguoilap.Properties.DisplayMember = "HoTen"
        LookUpnguoilap.EditValue = 0
        DateEditngaylapthe.EditValue = DateTime.Now.ToLongDateString()

    End Sub

    Private Sub GroupControl1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles GroupControl1.Paint

    End Sub

    Private Sub btnlapthe_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlapthe.Click
        If DateEditngaysinh.DateTime.Year >= DateTime.Now.Year - 18 Then
            MessageBox.Show("Doc gia phai tren 18 tuoi !")
            Return
        End If

        Dim sql As String = "Insert INTO DOCGIA(TenDocGia,MaLoaiDocGia,NgaySinh,DiaChi,Email,NgayLapThe,MaNhanVien) "
        sql = sql + "Values(" + "'" + txthoten.Text + "'" + "," + LookUpEdit_LoaiDocGia.EditValue.ToString() + "," + "'" + DateEditngaysinh.DateTime + "'" + ","
        sql = sql + "'" + txtdiachi.Text + "'" + "," + "'" + txtemail.Text + "'" + "," + "'" + DateEditngaylapthe.DateTime + "'" + "," + LookUpnguoilap.EditValue.ToString() + ")"

        Dim bus As New DocGiaBUS()
        Dim kq As Integer = bus.ThemDocGIa(sql)
        If kq = 1 Then
            MessageBox.Show("Thêm thành công !")
        Else
            MessageBox.Show("Thêm thất bại !")
        End If
    End Sub

    Private Sub btnthoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnthoat.Click
        Close()
    End Sub
End Class